package com.lagou.task17;

import java.io.*;


public class PrintWriterTest {
    public static void main(String[] args) {
        BufferedReader br = null;
        PrintStream ps = null;
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            ps = new PrintStream(new FileOutputStream("a.txt"));

            boolean notStop = true;
            while (notStop){
                String s1 = br.readLine();
                if ("bye".equals(s1)){
                    System.out.println("聊天结束");
                    notStop = false;
                }else {
                    ps.println(s1);
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (ps != null) {
                ps.close();
            }
            if (br != null) {

                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }


    }
}
